#------ Packages
library(car)
library(stargazer)
library(texreg)
library(effects)
library(multilevel)

#------Call data file
ndata = read.csv("Weighted Data for Paper.csv")


#-- Subset on no felony conviction
wdata = subset(ndata, ndata$con2 == 0)

#APPENDIX A: SURVEY MEASURES AND DESCRIPTIVE STATISTICS

## Cronbach's alpha of non-voting participation index
table(ndata$part_scale)
participation = cbind(ndata$write, ndata$pet, ndata$rally, ndata$polcamp)

cronbach(participation)

##APPENDIX TABLE 1: Descriptive Statistics of Sample
stargazer(ndata[c("disenfranchise" ,  "netcon_two" , "con2" , "inc" , "edu" , "woman" , "cleanfate" , "ideo5" , "polstop_freq" , "votereg")])


##APPENDIX TABLE 2: Social Ties, State Policy Regime, and Participation

table(ndata$voter , ndata$netcon_two , ndata$pol.fel)
table(ndata$write , ndata$netcon_two , ndata$pol.fel)
table(ndata$pet , ndata$netcon_two , ndata$pol.fel)
table(ndata$rally , ndata$netcon_two , ndata$pol.fel)
table(ndata$polcamp , ndata$netcon_two , ndata$pol.fel)

##MODELS
vote0 = lm(voter ~ disenfranchise + netcon_two + inc + edu + woman + cleanfate + ideo5 + polstop_freq + VoterID + PunRate, data = wdata, weight = wts_black)
summary(vote0)

vote1 = lm(voter ~ disenfranchise * netcon_two + inc + edu + woman + cleanfate + ideo5 + polstop_freq + VoterID + PunRate, data = wdata, weight = wts_black)
summary(vote1)


acts0 = lm(part_scale ~ disenfranchise + netcon_two + inc + edu + woman + cleanfate + ideo5 + polstop_freq + VoterID + PunRate, data = wdata, weight = wts_black)
summary(acts0)

acts1 = lm(part_scale ~ disenfranchise * netcon_two + inc + edu + woman + cleanfate + ideo5 + polstop_freq + VoterID + PunRate, data = wdata, weight = wts_black)
summary(acts1)


##APPENDIX TABLE 3: Table 1 from paper, including control variables

texreg(list(vote0, vote1, acts0, acts1),
       custom.coef.names = c( 
         "(Intercept)",
         "Disenfranchise",
         "Social Ties",
         "Income", 
         "Education", 
         "Woman",
         "Linked Fate",
         "Ideology", 
         "Stopped by Police",
         "Voter ID Law",
         "Punishment Rate",
         "Disenfranchise*Ties"
       ),
       custom.model.names = c("1: Voting Participation", "2: Voting Participation", "3: Non-Voting Participation", "4: Non-Voting Participation" ),
       dcolumn = TRUE, booktabs = TRUE, use.packages = FALSE, label  = "tab:AppTable3", stars = c( .10, 0.05), caption = "Table 1 from paper, including control variables", float.pos = "hb", single.row = TRUE) 


##APPENDIX B: ROBUSTNESS CHECKS


#including respondents with felony convictions

vote0.ALL = lm(voter ~ disenfranchise + netcon_two + inc + edu + woman + cleanfate + ideo5 + polstop_freq + VoterID + PunRate, data = ndata, weight = wts_black)
summary(vote0.ALL)

vote1.ALL = lm(voter ~ disenfranchise * netcon_two + inc + edu + woman + cleanfate + ideo5 + polstop_freq + VoterID + PunRate, data = ndata, weight = wts_black)
summary(vote1.ALL)

acts0.ALL = lm(part_scale ~ disenfranchise + netcon_two + inc + edu + woman + cleanfate + ideo5 + polstop_freq + VoterID + PunRate, data = ndata, weight = wts_black)
summary(acts0.ALL)


acts1.ALL = lm(part_scale ~ disenfranchise * netcon_two + inc + edu + woman + cleanfate + ideo5 + polstop_freq + VoterID + PunRate, data = ndata, weight = wts_black)
summary(acts1.ALL)


##APPENDIX TABLE 4: Robustness Checks: Including Respondents with Felony Convictions
texreg(list(vote0.ALL, vote1.ALL, acts0.ALL, acts1.ALL),
       custom.coef.names = c( 
         "(Intercept)",
         "Disenfranchised State",
         "Social Ties",
         "Income", 
         "Education", 
         "Woman",
         "Linked Fate",
         "Ideology", 
         "Stopped by Police",
         "Voter ID Law",
         "Punishment Rate",
         "Disenfranchised*Ties"
       ),
       custom.model.names = c("1: Voting Participation", "2: Voting Participation", "3: Non-Voting Participation", "4: Non-Voting Participation" ),
       dcolumn = TRUE, booktabs = TRUE, use.packages = FALSE, label  = "tab:AppTable4", stars = c(0.05, 0.10), caption = "Robustness Checks: Including Respondents with Felony Convictions", float.pos = "hb", single.row = TRUE) 


##add control var for felony conviction 

vote0.ALL2 = lm(voter ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate  + con2, data = ndata, weight = wts_black)
summary(vote0.ALL2)

vote1.ALL2 = lm(voter ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate + con2, data = ndata, weight = wts_black)
summary(vote1.ALL2)

acts0.ALL2 = lm(part_scale ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate  + con2, data = ndata, weight = wts_black)
summary(acts0.ALL2)


acts1.ALL2 = lm(part_scale ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate  + con2, data = ndata, weight = wts_black)
summary(acts1.ALL2)


##APPENDIX TABLE 5: Robustness Checks: Including Respondents with Felony Convictions, controlling for conviction status
texreg(list(vote0.ALL2, vote1.ALL2, acts0.ALL2, acts1.ALL2),
       custom.coef.names = c( 
         "(Intercept)",
         "Disenfranchised State",
         "Social Ties",
         "Income", 
         "Education", 
         "Woman",
         "Linked Fate",
         "Ideology", 
         "Stopped by Police",
         "Voter ID Law",
         "Punishment Rate",
         "Felony Conviction",
         "Disenfranchised*Ties"
       ),
       custom.model.names = c("1: Voting Participation", "2: Voting Participation", "3: Non-Voting Participation", "4: Non-Voting Participation" ),
       dcolumn = TRUE, booktabs = TRUE, use.packages = FALSE, label  = "tab:AppTable5", stars = c(0.05, 0.10), caption = "Robustness Checks: Including Respondents with Felony Convictions, controlling for conviction status", float.pos = "hb", single.row = TRUE)



# ----- Robustness Check 1 +  Connections
names(ndata)
table(ndata$netcon_two)
table(wdata$netcon_two)
#Making network connection binary, 
#ie. 0 =  no connections; 1 =  1 +  connections
#Making network connection binary, 
#ie. 0 =  no connections; 1 =  1 +  connections
table(wdata$netcon2)
wdata$netcon_bi  = rep(NA, length(wdata$respid))
wdata$netcon_bi  = recode(wdata$netcon2, "0 = 0; 1 = 1; 2 = 1; else =  NA")
table(wdata$netcon_bi)




vote0.1 = lm(voter ~ disenfranchise + netcon_bi  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate, data = wdata, weight = wts_black)
summary(vote0.1)

vote1.1 = lm(voter ~ disenfranchise * netcon_bi  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate, data = wdata, weight = wts_black)
summary(vote1.1)



acts0.1 = lm(part_scale ~ disenfranchise + netcon_bi  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate, data = wdata, weight = wts_black)
summary(acts0.1)

acts1.1 = lm(part_scale ~ disenfranchise * netcon_bi  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate, data = wdata, weight = wts_black)
summary(acts1.1)

##APPENDIX TABLE 6: Robustness Checks: Including Respondents with 3+ Connections
texreg(list(vote0.1, vote1.1, acts0.1, acts1.1),
       custom.coef.names = c( 
         "(Intercept)",
         "Disenfranchised State",
         "Social Ties",
         "Income",
         "Education", 
         "Woman",
         "Linked Fate",
         "Ideology", 
         "Stopped by Police",
         "Voter ID Law",
         "Punishment Rate",         
         "Disenfranchised*Ties"
       ),
       custom.model.names = c("1: Voting Participation", "2: Voting Participation", "3: Non-Voting Participation", "4: Non-Voting Participation"),
       dcolumn = TRUE, booktabs = TRUE, use.packages = FALSE, label  = "tab:AppTable6", stars = c(0.1, 0.05), caption = "Robustness Checks: Including Respondents with 3 +  Connections", float.pos = "hb", single.row = TRUE)




##separate out participatory acts

write0 = lm(write ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate, data = wdata, weight = wts_black)
summary(write0)

write1 = lm(write ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate, data = wdata, weight = wts_black)
summary(write1)


pet0 = lm(pet ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate, data = wdata, weight = wts_black)
summary(pet0)

pet1 = lm(pet ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate, data = wdata, weight = wts_black)
summary(pet1) 

rally0 = lm(rally ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate, data = wdata, weight = wts_black)
summary(rally0)

rally1 = lm(rally ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate, data = wdata, weight = wts_black)
summary(rally1) 

polcamp0 = lm(polcamp ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate, data = wdata, weight = wts_black)
summary(polcamp0)

polcamp1 = lm(polcamp ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate, data = wdata, weight = wts_black)
summary(polcamp1) 


##APPENDIX TABLE 7: Robustness Checks: Separating Out Participatory Acts
texreg(list(write0, write1, pet0, pet1),
       custom.coef.names = c( 
         "(Intercept)",
         "Disenfranchised State",
         "Social Ties",
         "Income", 
         "Education", 
         "Woman",
         "Linked Fate",
         "Ideology", 
         "Stopped by Police",
         "Voter ID Law",
         "Punishment Rate",
         "Disenfranchised*Ties"
       ),
       custom.model.names = c("1: Write", "2: Write", "3: Petition", "4: Petition"),
       dcolumn = TRUE, booktabs = TRUE, use.packages = FALSE, label  = "tab:AppTable7", stars = c(0.05, 0.10), caption = "Robustness Checks: Separating Out Participatory Acts", float.pos = "hb", single.row = TRUE)



##APPENDIX TABLE 8: Robustness Checks: Separating Out Participatory Acts

texreg(list(rally0, rally1, polcamp0, polcamp1),
       custom.coef.names = c( 
         "(Intercept)",
         "Disenfranchised State",
         "Social Ties",
         "Income", 
         "Education", 
         "Woman",
         "Linked Fate",
         "Ideology", 
         "Stopped by Police",
         "Voter ID Law",
         "Punishment Rate",
         "Disenfranchised*Ties"
       ),
       custom.model.names = c("1: Protest", "2: Protest", "3: Campaign", "4:Campaign" ),
       dcolumn = TRUE, booktabs = TRUE, use.packages = FALSE, label  = "tab:AppTable8", stars = c(0.05, 0.10), caption = "Robustness Checks: Separating Out Participatory Acts", float.pos = "hb", single.row = TRUE)

##EFFECT SIZES FOR PROTEST AND CAMPAIGN
ef3 = effect("disenfranchise : netcon_two", rally1) 
ef3

d3 = as.data.frame(ef3) #save as data frame
d3

#Save only estimates at 1 and 0
effects.rally = subset(d3, disenfranchise == 0 | disenfranchise == 1)
effects.rally

effects.rally = subset(effects.rally, netcon_two == 0 | netcon_two == 1)
effects.rally


ef4 = effect("disenfranchise : netcon_two", polcamp1) 
ef4

d4 = as.data.frame(ef4) #save as data frame
d4

#Save only estimates at 1 and 0
effects.campaign = subset(d4, disenfranchise == 0 | disenfranchise == 1)
effects.campaign

effects.campaign = subset(effects.campaign, netcon_two == 0 | netcon_two == 1)
effects.campaign

##LOGITS, ORDERED LOGITS

vote0.glm = glm(voter ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate, data = wdata, weight = wts_black, family = binomial(link = "logit"))
summary(vote0.glm)

vote1.glm = glm(voter ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate, data = wdata, weight = wts_black, family = binomial(link = "logit"))
summary(vote1.glm)

acts0.polr = polr(as.factor(part_scale) ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate, data = wdata, weight = wts_black, Hess = TRUE, method = c("logistic"))
summary(acts0.polr)
ctable0  = coef(summary(acts0.polr))
p0  = pnorm(abs(ctable0[, "t value"]), lower.tail = FALSE) * 2
ctable0  = cbind(ctable0, "p value" = p0)

acts1.polr = polr(as.factor(part_scale) ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate, data = wdata, weight = wts_black, Hess = TRUE, method = c("logistic"))
summary(acts1.polr)
ctable1  = coef(summary(acts1.polr))
p1  = pnorm(abs(ctable1[, "t value"]), lower.tail = FALSE) * 2
ctable1  = cbind(ctable1, "p value" = p1)


##APPENDIX TABLE 9: Robustness Checks: Logistic Regression and Ordered Logistic Regressions
texreg(list(vote0.glm, vote1.glm, acts0.polr, acts1.polr),
       custom.coef.names = c( 
         "(Intercept)",
         "Disenfranchised State",
         "Social Ties",
         "Income", 
         "Education", 
         "Woman",
         "Linked Fate",
         "Ideology", 
         "Stopped by Police",
         "Voter ID Law",
         "Punishment Rate",
         "Disenfranchised*Ties"
       ),
       custom.model.names = c("1: Voting Participation", "2: Voting Participation", "3: Non-Voting Participation", "4: Non-Voting Participation" ),
       dcolumn = TRUE, booktabs = TRUE, use.packages = FALSE, label  = "tab:AppTable9", stars = c(0.05, 0.10), caption = "Robustness Checks: Logistic Regression and Ordered Logistic Regressions", float.pos = "hb", single.row = TRUE)


##regional controls

vote0.region = lm(voter ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate + region, data = wdata, weight = wts_black)
summary(vote0.region)

vote1.region = lm(voter ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate +  region, data = wdata, weight = wts_black)
summary(vote1.region)

acts0.region = lm(part_scale ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate + region, data = wdata, weight = wts_black)
summary(acts0.region)

acts1.region = lm(part_scale ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate + region, data = wdata, weight = wts_black)
summary(acts1.region)

##APPENDIX TABLE 10: Robustness Checks: Regional Controls

texreg(list(vote0.region, vote1.region, acts0.region, acts1.region),
       custom.coef.names = c( 
         "(Intercept)",
         "Disenfranchised State",
         "Social Ties",
         "Income", 
         "Education", 
         "Woman",
         "Linked Fate",
         "Ideology", 
         "Stopped by Police",
         "Voter ID Law",
         "Punishment Rate",
         "Northeast",
         "South",
         "West",
         "Disenfranchised*Ties"
       ),
       custom.model.names = c("1: Voting Participation", "2: Voting Participation", "3: Non-Voting Participation", "4: Non-Voting Participation" ),
       dcolumn = TRUE, booktabs = TRUE, use.packages = FALSE, label  = "tab:AppTable10", stars = c(0.05, 0.10), caption = "Robustness Checks: Regional Controls", float.pos = "hb", single.row = TRUE)


##nonsouth models
nonsouth = subset(wdata, wdata$region !=  "South")
table(nonsouth$region)

vote0.nonsouth = lm(voter ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate , data = nonsouth, weight = wts_black)
summary(vote0.nonsouth)

vote1.nonsouth = lm(voter ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate, data = nonsouth, weight = wts_black)
summary(vote1.nonsouth)

acts0.nonsouth = lm(part_scale ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate , data = nonsouth, weight = wts_black)
summary(acts0.nonsouth)

acts1.nonsouth = lm(part_scale ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate , data = nonsouth, weight = wts_black)
summary(acts1.nonsouth)


##APPENDIX TABLE 11: Robustness Checks: Non-Southern States

texreg(list(vote0.nonsouth, vote1.nonsouth, acts0.nonsouth, acts1.nonsouth),
       custom.coef.names = c( 
         "(Intercept)",
         "Disenfranchised State",
         "Social Ties",
         "Income", 
         "Education", 
         "Woman",
         "Linked Fate",
         "Ideology", 
         "Stopped by Police",
         "Voter ID Law",
         "Punishment Rate",
         "Disenfranchised*Ties"
       ),
       custom.model.names = c("1: Voting Participation", "2: Voting Participation", "3: Non-Voting Participation", "4: Non-Voting Participation" ),
       dcolumn = TRUE, booktabs = TRUE, use.packages = FALSE, label  = "tab:AppTable11", stars = c(0.05, 0.10), caption = "Robustness Checks: Non-Southern States", float.pos = "hb", single.row = TRUE)


##southern states

south = subset(wdata, wdata$region ==  "South")
table(south$region)

vote0.south = lm(voter ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate , data = south, weight = wts_black)
summary(vote0.south)

vote1.south = lm(voter ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate, data = south, weight = wts_black)
summary(vote1.south)

acts0.south = lm(part_scale ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate , data = south, weight = wts_black)
summary(acts0.south)


acts1.south = lm(part_scale ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate , data = south, weight = wts_black)
summary(acts1.south)


##APPENDIX TABLE 12: Robustness Checks: Southern States

texreg(list(vote0.south, vote1.south, acts0.south, acts1.south),
       custom.coef.names = c( 
         "(Intercept)",
         "Disenfranchised State",
         "Social Ties",
         "Income", 
         "Education", 
         "Woman",
         "Linked Fate",
         "Ideology", 
         "Stopped by Police",
         "Voter ID Law",
         "Punishment Rate",
         "Disenfranchised*Ties"
       ),
       custom.model.names = c("1: Voting Participation", "2: Voting Participation", "3: Non-Voting Participation", "4: Non-Voting Participation" ),
       dcolumn = TRUE, booktabs = TRUE, use.packages = FALSE, label  = "tab:AppTable12", stars = c(0.05, 0.10), caption = "Robustness Checks: Southern States", float.pos = "hb", single.row = TRUE)




# Robustness check: percent disenfranchised in state 

vote0.pctd = lm(voter ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate + PctDisenfranchised, data = wdata, weight = wts_black)
summary(vote0.pctd)

vote1.pctd = lm(voter ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate +  PctDisenfranchised, data = wdata, weight = wts_black)
summary(vote1.pctd)

acts0.pctd = lm(part_scale ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate + PctDisenfranchised, data = wdata, weight = wts_black)
summary(acts0.pctd)


acts1.pctd = lm(part_scale ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate + PctDisenfranchised, data = wdata, weight = wts_black)
summary(acts1.pctd)


##using black disenfranchisement percent
vote0.pctbd = lm(voter ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate + PctBlackDisenfranchised, data = wdata, weight = wts_black)
summary(vote0.pctbd)

vote1.pctbd = lm(voter ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate +  PctBlackDisenfranchised, data = wdata, weight = wts_black)
summary(vote1.pctbd)

acts0.pctbd = lm(part_scale ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate + PctBlackDisenfranchised, data = wdata, weight = wts_black)
summary(acts0.pctbd)

acts1.pctbd = lm(part_scale ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate + PctBlackDisenfranchised, data = wdata, weight = wts_black)
summary(acts1.pctbd)


##APPENDIX TABLE 13: Robustness Checks: Percent Disenfranchised in State
texreg(list(vote0.pctd, vote1.pctd, acts0.pctd, acts1.pctd),
       custom.coef.names = c( 
         "(Intercept)",
         "Disenfranchised State",
         "Social Ties",
         "Income", 
         "Education", 
         "Woman",
         "Linked Fate",
         "Ideology", 
         "Stopped by Police",
         "Voter ID Law",
         "Punishment Rate",
         "$%$ Disenfranchised",
         "Disenfranchised*Ties"
       ),
       custom.model.names = c("1: Voting Participation", "2: Voting Participation", "3: Non-Voting Participation", "4: Non-Voting Participation" ),
       dcolumn = TRUE, booktabs = TRUE, use.packages = FALSE, label  = "tab:AppTable13", stars = c(0.05, 0.10), caption = "Robustness Checks: Percent Disenfranchised in State", float.pos = "hb", single.row = TRUE)


##APPENDIX TABLE 14: Robustness Checks: Percent of Blacks Disenfranchised in State
texreg(list(vote0.pctbd, vote1.pctbd, acts0.pctbd, acts1.pctbd),
       custom.coef.names = c( 
         "(Intercept)",
         "Disenfranchised State",
         "Social Ties",
         "Income", 
         "Education", 
         "Woman",
         "Linked Fate",
         "Ideology", 
         "Stopped by Police",
         "Voter ID Law",
         "Punishment Rate",
         "$%$ Black Disenfranchised",
         "Disenfranchised*Ties"
       ),
       custom.model.names = c("1: Voting Participation", "2: Voting Participation", "3: Non-Voting Participation", "4: Non-Voting Participation" ),
       dcolumn = TRUE, booktabs = TRUE, use.packages = FALSE, label  = "tab:AppTable14", stars = c(0.05, 0.10), caption = "Robustness Checks: Percent of Blacks Disenfranchised in State", float.pos = "hb", single.row = TRUE)



##ALTERNATIVE WEIGHTS SPECIFICATION

altweight = read.csv("Alternative Weighted Data for Appendix.csv")

vote0.alt =  lm(voter ~ disenfranchise + netcon_two + inc + edu + woman + cleanfate + ideo5 + polstop_freq + VoterID + PunRate, data = altweight, weight = wts_black)
summary(vote0.alt)

vote1.alt = lm(voter ~ disenfranchise * netcon_two + inc + edu + woman + cleanfate + ideo5 + polstop_freq + VoterID + PunRate, data = altweight, weight = wts_black)
summary(vote1.alt)

#Non-Voting Participation Models
acts0.alt = lm(part_scale ~ disenfranchise + netcon_two + inc + edu + woman + cleanfate + ideo5 + polstop_freq + VoterID + PunRate, data = altweight, weight = wts_black)
summary(acts0.alt)

acts1.alt = lm(part_scale ~ disenfranchise * netcon_two + inc + edu + woman + cleanfate + ideo5 + polstop_freq + VoterID + PunRate, data = altweight, weight = wts_black)
summary(acts1.alt)

##APPENDIX TABLE 15
texreg(list(vote0, vote1, acts0, acts1),
       custom.coef.names = c( 
         "(Intercept)",
         "Disenfranchise",
         "Social Ties",
         "Income", 
         "Education", 
         "Woman",
         "Linked Fate",
         "Ideology", 
         "Stopped by Police",
         "Voter ID Law",
         "Punishment Rate",
         "Disenfranchise*Ties"
       ),
       custom.model.names = c("1: Voting Participation", "2: Voting Participation", "3: Non-Voting Participation", "4: Non-Voting Participation" ),
       dcolumn = TRUE, booktabs = TRUE, use.packages = FALSE, label  = "tab:AppTable15", stars = c(0.05, 0.10), caption = "Robustness Check: Interaction of State Policy and Social Connections Predicting Participation with Alternative Specification of Survey Weights", float.pos = "hb", single.row = TRUE) 



##STATE FIXED EFFECTS MODELS

vote0.FE = lm(voter ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate + as.factor(state), data = wdata, weight = wts_black)
summary(vote0.FE)

vote1.FE = lm(voter ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate +  as.factor(state), data = wdata, weight = wts_black)
summary(vote1.FE)

acts0.FE = lm(part_scale ~ disenfranchise  + netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate +  as.factor(state), data = wdata, weight = wts_black)
summary(acts0.FE)

acts1.FE = lm(part_scale ~ disenfranchise * netcon_two  + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate +  as.factor(state), data = wdata, weight = wts_black)
summary(acts1.FE)


##APPENDIX TABLE 16: Robustness Checks: State Fixed Effects Models
texreg(list(vote0.FE, vote1.FE, acts0.FE, acts1.FE),
       custom.coef.names = c( 
         "(Intercept)",
         "Disenfranchised State",
         "Social Ties",
         "Income", 
         "Education", 
         "Woman",
         "Linked Fate",
         "Ideology", 
         "Stopped by Police",
         "Voter ID Law",
         "Punishment Rate",
         "State1",
         "State2",
         "State3",
         "State4",
         "State5",
         "State6",
         "State7",
         "State8",
         "State9",
         "State10",
         "State11",
         "State12",
         "State13",
         "State14",
         "State15",
         "State16",
         "State17",
         "State18",
         "State19",
         "State20",
         "State21",
         "State22",
         "State23",
         "State24",
         "State25",
         "State26",
         "State27",
         "State28",
         "State29",
         "State30",
         "State31",
         "State32",
         "State33",
         "State34",
         
         "Disenfranchised*Ties"
       ),
       custom.model.names = c("1: Voting Participation", "2: Voting Participation", "3: Non-Voting Participation", "4: Non-Voting Participation" ),
       dcolumn = TRUE, booktabs = TRUE, use.packages = FALSE, label  = "tab:AppTable16", stars = c(0.05, 0.10), caption = "Robustness Checks: State Fixed Effects Models", float.pos = "hb", single.row = TRUE)





##Are key independent variables exogeneous?

ties1  = lm(netcon_two ~ disenfranchise + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate, data = wdata, weight = wts_black)
summary(ties1)


ties2  = lm(netcon_two ~ disenfranchise + inc + edu + woman + cleanfate +  ideo5 + polstop_freq + VoterID  + PunRate + as.factor(state), data = wdata, weight = wts_black)
summary(ties2)


##APPENDIX TABLE 17: Testing Endogeneity of State Policy and Connections
texreg(list(ties1, ties2),
       custom.coef.names = c( 
         "(Intercept)",
         "Disenfranchisement Policy",
         "Income",
         "Education", 
         "Woman",
         "Linked Fate",
         "Ideology", 
         "Stopped by Police",
         "Voter ID Law",
         "Punishment Rate",
         "State1",
         "State2",
         "State3",
         "State4",
         "State5",
         "State6",
         "State7",
         "State8",
         "State9",
         "State10",
         "State11",
         "State12",
         "State13",
         "State14",
         "State15",
         "State16",
         "State17",
         "State18",
         "State19",
         "State20",
         "State21",
         "State22",
         "State23",
         "State24",
         "State25",
         "State26",
         "State27",
         "State28",
         "State29",
         "State30",
         "State31",
         "State32",
         "State33",
         "State34"
       ),
       custom.model.names = c("1: Social Ties", "2: Social Ties"),
       dcolumn = TRUE, booktabs = TRUE, use.packages = FALSE, label  = "tab:AppTable17", stars = c(0.05, 0.10), caption = "Testing Endogeneity of State Policy and Connections", float.pos = "hb", single.row = TRUE)


